home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gigarom 1
/
Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso
/
FILES
/
CDE
/
I-N
/
NeXT WDef III.sit
/
NeXT WDef 3.0
/
source
/
NeXT wdef.c
next >
Wrap
C/C++ Source or Header
|
1993-04-05
|
33KB
|
1,163 lines
/*
——————————————————————————————
My Window Definition Procedure
——————————————————————————————
This s that odd window.
————————
89/04/20
————————
1.0 89/03/31 First draft based on clock window def proc (+A5 games ).
89/04/05 Fixed problem with zoom box hilite
89/04/06 Fixed zooming
89/04/07 Minor changes in draw, chose from two gray patterns
to avoid odd mismatches in window dragged onscreen
from offscreen, added proper plainDBox & altDBoxProc
variations, special cased zero width titles.
1.1 89/04/09 Odd half erased scroll bar startup MPW adjusted
[see DrawMyGrowIcon()]
1.2 89/04/09 Fixed problem with userState updates. Working on colors!
89/04/11 Changed size box to chevrons.
89/04/12 Made sure inGrow only returned on hilited windows.
89/04/20 Added Apples screenBits workaround and scroll area
to grow image.
2.0 89/11/10 Finished color additions and cleaned up other
assorted bugs. JNP
Changes made by Josh Pritikin ( 11.10.89 ):
1. In CalculateMyWindow I added a test to see if we have a color window.
2. I removed the ugly StuffHex calls and speeded the pattern packing up.
3. I added a gunk of code and special casing to totally support ColorQD!
4. The code is admitably gross in some (most) places but it works and should
serve as an example of what not to make your code look like.
GEnie: J.Pritikin
AppleLink: D4991 ( <- this will change soon )
Internet: 6500stom@ucsbuxa.ucsb.edu
3.0 93/03/22 Updated for full color support. Rewrote code for Think C 5.x.
Changes made by Anthony D. Saxton ( 2/26/93 ):
1. Rewrote code throughout for more efficient use of Think C 5.x.
2. Added Color button Icons for 2, 4 and 8 bit modes.
3. Added support for colorized windows as well as Apples "Color" cdev.
4. Added support for ALL documented window types & frames for the others!
5. Corrected Icon bug and added 3D movement!
6. Corrected GoAway button presence in movable dialog windows.
The Copyright Notice in “CopyRight()” Is Not To Be Removed! Use Of This Code In
Commercial Software By License Only. Contact Anthony D. Saxton, Of Elenay™ Creations
For Licensing Information. Use Of This Code In FreeWare, Requires Only Contact Of
Elenay™ Creations. This Copyright Applies To All Code Segments Of This WDEF.
All Changes Are Copyright ©1993, by Elenay Creations
5686 Big Sea Street
Las Vegas, NV, USA
89110
(702) 453-0270
AOL: Elenay
Internet: elenay_creations@tcs.las-vegas.nv.us
—————————————————————————————————————————————————
Public Domain 1989 by Appropriate Technology
—————————————————————————————————————————————————
Changes - Copyright ©1993 by Elenay™ Creations
—————————————————————————————————————————————————
Please send a copy of changes/improvements to:
Eric Celeste, Appropriate Technology, 358 North Parkview, Columbus, OH 43209, USA.
CompuServe: 76146,724. MacNET: Celeste.
——————————————————————————————————————————————————————————————————————
Note: This WDEF is coded in THINK C 5.0.3 from Think Technologies
——————————————————————————————————————————————————————————————————————
*/
#include "NeXT wdef.h"
pascal long main( int variation, WindowPtr window, int message, long parameter )
{
long result = 0L; /* the return code for the function */
switch( message )
{
case( wDraw ):
DrawMyWindow( variation, window, parameter );
break;
case( wHit ):
result = HitMyWindow( variation, window, parameter );
break;
case( wCalcRgns ):
CalculateMyWindow( variation, window, parameter );
break;
case( wNew ):
SetupWindow( variation, window, parameter );
break;
case( wDispose ):
KillWindow( variation, window, parameter );
break;
case( wGrow ):
GrowMyWindow( variation, window, parameter );
break;
case( wDrawGIcon ):
DrawMyGrowIcon( variation, window, parameter );
break;
}
return( result );
}
/*————————————————————
create an RGB gray of this brightness.
————————————————————*/
RGBColor PackGray( int brightness )
{
RGBColor gray;
gray.red = gray.green = gray.blue = brightness;
return gray;
}
/*————————————————————
where was my window hit?
————————————————————*/
long HitMyWindow( int variation, WindowPtr window, long parameter )
{
Point hitLocation;
Rect windowRect,
thisRect;
long result;
result = wNoHit;
SetPt( &hitLocation, LoWord( parameter ), HiWord( parameter ) );
if ( PtInRgn( hitLocation, theWindow.strucRgn ) )
{
windowRect = (**theWindow.strucRgn).rgnBBox;
if ( PtInRgn( hitLocation, theWindow.contRgn ) )
{
result = wInContent; /* in the content region */
if ( theWindow.hilited )
if ( (variation & 7) == documentProc )
{
SetRect( &thisRect, windowRect.right - 17, windowRect.bottom - 17,
windowRect.right - 3, windowRect.bottom - 3 );
if ( PtInRect( hitLocation, &thisRect ) )
result = wInGrow;
}
} else
{
switch( variation & 7 )
{
case( documentProc ):
case( noGrowDocProc ):
case( movableDBoxProc ):
result = wInDrag; /* in the drag area unless */
if ( theWindow.hilited )
{
if ( theWindow.goAwayFlag && variation != movableDBoxProc )
{
SetRect( &thisRect, windowRect.left + 5, windowRect.top + 5,
windowRect.left + 18, windowRect.top + 18 );
if ( PtInRect( hitLocation, &thisRect ) )
result = wInGoAway;
}
if ( result == wInDrag && theWindow.zoomFlag )
{
SetRect( &thisRect, windowRect.right - 17, windowRect.top + 5,
windowRect.right - 4, windowRect.top + 18 );
if ( PtInRect( hitLocation, &thisRect ) && theWindow.dataHandle )
{
thisRect = (**theWindow.contRgn).rgnBBox;
if ( EqualRect ( &(wDataHandle.stdState), &thisRect ) )
result = wInZoomIn;
else
{
wDataHandle.userState = thisRect;
result = wInZoomOut;
}
} /* in the zoom box */
} /* still dragging & zoomable */
} /* a hilited window */
if ( result == wInDrag )
{
thisRect = windowRect;
thisRect.top = (**theWindow.contRgn).rgnBBox.top;
if ( PtInRect( hitLocation, &thisRect ) )
result = wNoHit; // according to Apple's specs
} /* below title bar */
break;
} /* a moveable window */
} /* else not in content region */
} /* in the structure region */
return( result );
} /* end of HitMyWindow() */
/*————————————————————
calculate the regions of my window
————————————————————*/
CalculateMyWindow( int variation, WindowPtr window, long parameter )
{
Rect windowRect,
portR;
windowRect = window->portRect;
/* a fix for CWindowRecords */
if( window->portBits.rowBytes < 0xC000 ) /* Color Window? */
OffsetRect( &windowRect, -window->portBits.bounds.left, -window->portBits.bounds.top );
else
{
portR = (**(*(CWindowPtr)window).portPixMap).bounds;
OffsetRect( &windowRect, -portR.left, -portR.top );
}
RectRgn( theWindow.contRgn, &windowRect );
if ( (variation & 8) && !EqualRect( &(wDataHandle.stdState),&windowRect ) )
wDataHandle.userState = windowRect;
switch ( variation & 7 )
{
case ( documentProc ): /* a regular window */
case ( noGrowDocProc ): /* a regular window with no growing */
case ( movableDBoxProc ): /* a moveable dialog with no growing or close*/
OpenRgn();
InsetRect( &windowRect, -4, -4 );
windowRect.top -= 16; /* add room for the title bar */
MoveTo( windowRect.left, windowRect.top );
LineTo( windowRect.left, windowRect.bottom-2 );
LineTo( windowRect.left+2, windowRect.bottom );
LineTo( windowRect.right, windowRect.bottom );
LineTo( windowRect.right, windowRect.top+2 );
LineTo( windowRect.right-2, windowRect.top );
LineTo( windowRect.left, windowRect.top );
CloseRgn( theWindow.strucRgn );
break;
case ( dBoxProc ): /* dialog box variation */
OpenRgn();
InsetRect( &windowRect, -8, -8 );
MoveTo( windowRect.left, windowRect.top );
LineTo( windowRect.left, windowRect.bottom-2 );
LineTo( windowRect.left+2, windowRect.bottom );
LineTo( windowRect.right, windowRect.bottom );
LineTo( windowRect.right, windowRect.top+2 );
LineTo( windowRect.right-2, windowRect.top );
LineTo( windowRect.left, windowRect.top );
CloseRgn( theWindow.strucRgn );
break;
case ( altDBoxProc ): /* shadow box variation */
case ( altDBoxProc | 4 ): /* remain consistant W/ Apple */
OpenRgn();
InsetRect( &windowRect, -1, -1 );
MoveTo( windowRect.left, windowRect.top );
LineTo( windowRect.left, windowRect.bottom );
LineTo( windowRect.left+2, windowRect.bottom );
LineTo( windowRect.left+2, windowRect.bottom+2 );
LineTo( windowRect.right+2, windowRect.bottom+2 );
LineTo( windowRect.right+2, windowRect.top+2 );
LineTo( windowRect.right, windowRect.top+2 );
LineTo( windowRect.right, windowRect.top );
LineTo( windowRect.left, windowRect.top );
CloseRgn( theWindow.strucRgn );
break;
default: /* plain box variation (plainDBox) and others */
InsetRect( &windowRect, -1, -1 );
RectRgn( theWindow.strucRgn, &windowRect );
break;
}
} /* end of CalculateMyWindow() */
/*————————————————————
set up the window
————————————————————*/
SetupWindow( int variation, WindowPtr window, long parameter )
{
SysEnvRec thisWorld;
OSErr err;
GDHandle thisDevice;
Rect thisRect;
GrafPtr savePort;
GrafPort tempPort;
thisDevice = nil;
theWindow.dataHandle = nil;
theWindow.dataHandle = NewHandle( (long)sizeof( WSDRecord ) );
if ( variation == ( documentProc+8 ) || variation == ( noGrowDocProc+8 ) ||
variation == ( movableDBoxProc+8 ) )
{
theWindow.zoomFlag = true;
if ( theWindow.dataHandle )
{
err = SysEnvirons( 1, &thisWorld );
if ( !err && thisWorld.hasColorQD )
{
thisDevice = GetMainDevice();
thisRect = (**thisDevice).gdRect;
thisRect.top += MBarHeight;
} else
{
GetPort( &savePort ); /* finding screenBits w/o globals */
OpenPort( &tempPort );
thisRect = tempPort.portRect;
SetPort( savePort );
ClosePort( &tempPort );
thisRect.top += MBarHeight; /* make way for the menubar */
}
InsetRect( &thisRect, 4, 4 ); /* make way for edges */
thisRect.top += 16; /* make way for what's left of title */
wDataHandle.stdState = thisRect;
wDataHandle.userState = thisRect;
}
} else
theWindow.zoomFlag = false;
buttonState = 0;
} /* end of SetupWindow() */
/*————————————————————
kill the window
————————————————————*/
KillWindow( int variation, WindowPtr window, long parameter )
{
if ( theWindow.dataHandle )
{
DisposHandle( theWindow.dataHandle );
theWindow.dataHandle = nil;
}
} /* end of KillWindow() */
/*————————————————————
draw the growing outline, the pen is already set
————————————————————*/
GrowMyWindow( int variation, WindowPtr window, long parameter )
{
Rect growingRect;
growingRect = *(RectPtr)parameter;
growingRect.top -= 20; /* out to full size */
growingRect.left -= 4;
growingRect.bottom += 4;
growingRect.right += 4;
FrameRect( &growingRect ); /* the frame */
growingRect.top += 19;
MoveTo( growingRect.left, growingRect.top ); /* the title bar area */
LineTo( growingRect.right, growingRect.top );
MoveTo( growingRect.right - 19, growingRect.top ); /* the scroll area */
LineTo( growingRect.right - 19, growingRect.bottom );
MoveTo( growingRect.left, growingRect.bottom - 19 );
LineTo( growingRect.right, growingRect.bottom - 19 );
} /* end of GrowMyWindow() */
/*————————————————————
draw the size box and the scroll frame
————————————————————*/
DrawMyGrowIcon( int variation, WindowPtr window, long parameter )
{
Boolean hasColorQD;
Rect thisRect;
SysEnvRec thisWorld;
RGBColor myRGB;
CGrafPtr wPort;
GDHandle aDevice;
RgnHandle saveClip,
tempRgn;
AuxWinHandle theAuxWin;
theAuxWin = nil;
SetPort( window );
if ( !SysEnvirons( 1, &thisWorld ) )
hasColorQD = thisWorld.hasColorQD;
else
hasColorQD = false;
if ( hasColorQD )
{
GetAuxWin( window, &theAuxWin );
if ( theAuxWin )
{
/* The code below makes sure the System 7 colors are found even when the window color
table is defined with only 5 colors! This determines if the Grow Icon will be drawn
in color or b/w. */
if ( (*(*theAuxWin)->awCTable)->ctSize < 12 )
GetAuxWin( nil, &theAuxWin );
if ( (*(*theAuxWin)->awCTable)->ctSize >= 12 )
myRGB = (*(*theAuxWin)->awCTable)->ctTable[12].rgb;
else
myRGB.red = 0xFFFF; // Don't force b/w if Color cdev not used…
}
}
/*————————————————————
draw scroll bar frame
————————————————————*/
thisRect = window->portRect;
thisRect.left = thisRect.right - 15;
MoveTo( thisRect.left, thisRect.top );
LineTo( thisRect.left, thisRect.bottom );
thisRect.top = thisRect.bottom - 15;
thisRect.left = window->portRect.left;
MoveTo( thisRect.left, thisRect.top );
LineTo( thisRect.right, thisRect.top );
thisRect.left = thisRect.right - 14;
thisRect.top++;
EraseRect( &thisRect );
/*————————————————————
draw the sizing box
————————————————————*/
saveClip = NewRgn();
tempRgn = NewRgn();
GetClip( saveClip );
if ( hasColorQD && window->portBits.rowBytes < 0xC000 )
{
thisRect = (**theWindow.contRgn).rgnBBox;
thisRect.left = thisRect.right - 15;
thisRect.top = thisRect.bottom - 15;
thisRect.right += 1;
thisRect.bottom += 1;
GetCWMgrPort( &wPort );
SetPort( wPort );
} else
{
thisRect.right += 2;
thisRect.bottom += 2;
}
if ( theWindow.hilited )
{
if( hasColorQD )
{
aDevice = GetDeviceList();
do
{
if ( TestDeviceAttribute( aDevice, screenDevice ) &&
TestDeviceAttribute( aDevice, screenActive ) )
{
HLock( aDevice );
if ( RectInRgn( &(**aDevice).gdRect, saveClip ) )
{
RectRgn( tempRgn, &(**aDevice).gdRect );
SectRgn( saveClip, tempRgn, tempRgn );
SetClip( tempRgn );
if ( (**(**aDevice).gdPMap).cmpSize >= 2 &&
(myRGB.red|myRGB.green|myRGB.blue))
PlotCICN( thisRect,
"\xEA\xAA\xAA\xA8\x95\x41\x55\x48"
"\x95\x4A\x55\x48\x95\x4A\x01\x48"
"\x95\x4A\x2A\x48\x80\x1A\x2A\x48"
"\x8A\xAA\x2A\x48\x9A\xAA\x2A\x48"
"\x95\x55\x2A\x48\x94\x00\x6A\x48"
"\x94\xAA\xAA\x48\x95\xAA\xAA\x48"
"\x95\x55\x55\x48\x80\x00\x00\x18"
"\xFF\xFF\xFF\xF8\x00\x00\x00\x00"
); // The Color Grow Icon!
else
PlotSICN( thisRect,
"\xFF\xFC\xD1\x52\xAB\xA8\xD3\x12"
"\xAB\x78\x83\x72\xBF\x78\xFF\x72"
"\xAA\x78\xC0\x72\xAF\xF8\xDF\xF2"
"\xAA\xA8\x80\x02\xFF\xFE\x00\x00"
); // The b/w Grow Icon!
}
HUnlock( aDevice );
}
} while ( aDevice = GetNextDevice( aDevice ) );
} else
PlotSICN( thisRect,
"\xFF\xFC\xD1\x52\xAB\xA8\xD3\x12"
"\xAB\x78\x83\x72\xBF\x78\xFF\x72"
"\xAA\x78\xC0\x72\xAF\xF8\xDF\xF2"
"\xAA\xA8\x80\x02\xFF\xFE\x00\x00"
); // The b/w Grow Icon Again!
}
SetPort( window );
SetClip( saveClip );
DisposeRgn( saveClip );
DisposeRgn( tempRgn );
} /* end of DrawMyGrowIcon() */
/*————————————————————
draw the frame w/ color shadowing.
————————————————————*/
DrawFrame( PatsPtr pat, Rect frame, int width, Boolean drawColor )
{
frame.right -= 2;
frame.bottom -= 2;
PenSize( width, width );
if ( drawColor )
RGBForeColor( &pat->cFrameL );
else
PenPat( &pat->white );
FrameRect( &frame );
OffsetRect( &frame, 2, 2 );
if ( drawColor )
RGBForeColor( &pat->cFrameD );
else
PenPat( &pat->black );
FrameRect( &frame );
OffsetRect( &frame, -1, -1 );
if ( drawColor )
RGBForeColor( &pat->cGray );
else
PenPat( &pat->gray );
FrameRect( &frame );
} /* end of DrawFrame() */
/*————————————————————
draw an empty pane w/ shadowing
————————————————————*/
DrawPane( PatsPtr pat, Rect thisRect, Boolean drawColor )
{
/* fill the area with white */
if ( drawColor )
{
RGBForeColor( &pat->cTitle );
PenPat( &pat->black );
} else
PenPat( &pat->white );
PaintRect( &thisRect );
/* add the bottom shadow */
PenSize( 1, 1 );
if ( drawColor )
RGBForeColor( &pat->cFrameL );
else
PenPat( &pat->black );
MoveTo( thisRect.left+1, thisRect.bottom-1 );
LineTo( thisRect.right-1, thisRect.bottom-1 );
LineTo( thisRect.right-1, thisRect.top+1 );
/* add the top shadow */
if ( drawColor )
RGBForeColor( &pat->cFrameD );
MoveTo( thisRect.left, thisRect.bottom-1 );
LineTo( thisRect.left, thisRect.top );
LineTo( thisRect.right-1, thisRect.top );
} /* end of DrawPane() */
/*————————————————————
draw the title into the pane.
————————————————————*/
DrawWindowTitle( WindowPtr window, Rect titleRect, PatsPtr pat, Boolean hilited, Boolean drawColor )
{
int saveFont;
int saveSize;
Style saveFace;
Str255 windowTitle;
int titleWidth;
RgnHandle saveClip,
myClip;
GrafPtr wPort;
GetPort( &wPort );
saveFont = wPort->txFont;
saveSize = wPort->txSize;
saveFace = wPort->txFace;
TextFont( geneva );
TextSize( 9 );
TextFace( plain );
GetWTitle( window, windowTitle );
titleWidth = StringWidth( windowTitle );
if ( titleWidth > 0 )
{
titleWidth += 12; /* enough for edges */
if ( (titleRect.right - titleRect.left) > titleWidth )
titleRect.right = titleRect.left + titleWidth;
if ( hilited ) DrawPane( pat, titleRect, drawColor );
/* now shrink the box & set the clip region in case of a long title */
saveClip = NewRgn();
myClip = NewRgn();
GetClip( saveClip );
InsetRect( &titleRect, 1, 1 );
RectRgn( myClip, &titleRect );
SectRgn( saveClip, myClip, myClip );
SetClip( myClip );
/* now position ourselves & draw the title */
PenPat( &pat->black );
if ( drawColor )
{
if ( hilited )
{
RGBForeColor( &pat->cText );
RGBBackColor( &pat->cTitle );
} else
{
RGBForeColor( &pat->cWhite );
RGBBackColor( &pat->cGray );
}
}
MoveTo( titleRect.left + 5, titleRect.bottom - 2 );
DrawString( windowTitle );
SetClip( saveClip );
DisposeRgn( saveClip );
DisposeRgn( myClip );
} /* enough of a title to go with */
TextFont( saveFont );
TextSize( saveSize );
TextFace( saveFace );
} /* end of DrawWindowTitle() */
/*————————————————————
animate the close icon.
————————————————————*/
DrawGoAway( Rect frame, Boolean hilited, Boolean drawColor )
{
if ( hilited )
{
if ( drawColor )
PlotCICN( frame,
"\xBF\xFF\xFF\xF9\xEA\xAA\xAA\xAD\xE5\x55\x55\x4D\xE5\x55\x55\x4D"
"\xE5\x55\x55\x4D\xE5\x55\x55\x4D\xE5\x00\x00\x4D\xE4\x55\x56\x4D"
"\xE4\x55\x56\x4D\xE4\x55\x56\x4D\xE4\x55\x56\x4D\xE4\xAA\xAA\x4D"
"\xE5\x55\x55\x4D\xE0\x00\x00\x1D\xBF\xFF\xFF\xF9\x55\x55\x55\x55"
); // goAwayDown
else
PlotSICN( frame,
"\xFF\xFE\xFF\xFF\xEA\xAA\xD5\x53\xEA\xAA\xD5\x53\xE0\x0A\xC5\x53"
"\xEA\xBA\xC5\x53\xEA\xBA\xDF\xF3\xEA\xAA\xC0\x03\xFF\xFE\x55\x55"
); // goAwayDown (b/w)
} else
{
if ( drawColor )
PlotCICN( frame,
"\xBF\xFF\xFF\xF9\xD0\x00\x00\x0D\xC5\x55\x55\x6D\xC5\x55\x55\x6D"
"\xC5\x55\x55\x6D\xC5\x55\x55\x6D\xC5\x00\x00\x6D\xC4\x55\x56\x6D"
"\xC4\x55\x56\x6D\xC4\x55\x56\x6D\xC4\x55\x56\x6D\xC4\xAA\xAA\x6D"
"\xC5\x55\x55\x6D\xCA\xAA\xAA\xAD\xBF\xFF\xFF\xF9\x55\x55\x55\x55"
); // goAwayUp
else
PlotSICN( frame,
"\xFF\xFE\x80\x03\xAA\xAE\x95\x57\xAA\xAE\x95\x57\xA0\x0E\x85\x57"
"\xAA\xBE\x85\x57\xAA\xBE\x8F\xF7\xAA\xAE\xBF\xFF\xFF\xFE\x55\x55"
); // goAwayUp (b/w)
}
} /* end of DrawGoAway() */
/*————————————————————
animate the zoom icon.
————————————————————*/
DrawZoom( Rect frame, Boolean hilited, Boolean drawColor )
{
if ( hilited )
{
if ( drawColor )
PlotCICN( frame,
"\xBF\xFF\xFF\xF9\xEA\xAA\xAA\xAD\xE5\x55\x55\x4D\xE5\x00\x00\x4D"
"\xE4\x55\x56\x4D\xE4\x55\x56\x4D\xE4\x55\x56\x4D\xE4\x55\x56\x4D"
"\xE4\x55\x56\x4D\xE4\x55\x56\x4D\xE4\x55\x56\x4D\xE4\xAA\xAA\x4D"
"\xE5\x55\x55\x4D\xE0\x00\x00\x1D\xBF\xFF\xFF\xF9\x55\x55\x55\x55"
); // zoomDown
else
PlotSICN( frame,
"\xFF\xFE\xFF\xFF\xEA\xAA\xC0\x03\xEA\xBA\xC5\x53\xEA\xBA\xC5\x53"
"\xEA\xBA\xC5\x53\xEA\xBA\xCF\xF3\xEA\xAA\xC0\x03\xFF\xFE\x55\x55"
); // zoomDown (b/w)
} else
{
if ( drawColor )
PlotCICN( frame,
"\xBF\xFF\xFF\xF9\xD0\x00\x00\x0D\xC5\x55\x55\x6D\xC5\x00\x00\x6D"
"\xC4\x55\x56\x6D\xC4\x55\x56\x6D\xC4\x55\x56\x6D\xC4\x55\x56\x6D"
"\xC4\x55\x56\x6D\xC4\x55\x56\x6D\xC4\x55\x56\x6D\xC4\xAA\xAA\x6D"
"\xC5\x55\x55\x6D\xCA\xAA\xAA\xAD\xBF\xFF\xFF\xF9\x55\x55\x55\x55"
); // zoomUp
else
PlotSICN( frame,
"\xFF\xFE\x80\x07\xAA\xAE\x80\x17\xAA\xBE\x85\x57\xAA\xBE\x85\x57"
"\xAA\xBE\x85\x57\xAA\xBE\x9F\xF7\xAA\xAE\xFF\xFF\xFF\xFE\x55\x55"
);
}
} /* end of DrawZoom() */
/*————————————————————
draw the specified item
————————————————————*/
DrawOnce( long param, int var, WindowPtr window, Rect windowRect, PatsPtr pat, Boolean drawColor )
{
Rect thisRect;
switch ( (int)param )
{
case ( wNoHit ):
thisRect = windowRect;
PenNormal();
/* ——————————————————————————————————————— now for the more specific parts */
switch ( var & 7 )
{
case ( documentProc ): /* a regular window */
case ( noGrowDocProc ): /* a regular window with no grow box */
case ( movableDBoxProc ): /* a non-modal dialog */
DrawFrame( pat, thisRect, 2, drawColor );
InsetRect( &thisRect, 1, 1 );
thisRect.bottom = thisRect.top + 19;
if ( drawColor )
{
PenPat( &pat->black );
RGBForeColor( &pat->cGray );
} else
PenPat( &pat->gray );
PaintRect( &thisRect );
PenPat( &pat->black );
if ( drawColor )
RGBForeColor( &pat->cFrameD );
PenSize( 1, 1 );
MoveTo( windowRect.left+3, windowRect.top+19 );
LineTo( windowRect.right-4, windowRect.top+19 );
if ( theWindow.hilited )
{
/* ——————————————————————————————— the goaway box */
if ( theWindow.goAwayFlag && (var & 7) != movableDBoxProc )
{
SetRect( &thisRect,
windowRect.left + 3,
windowRect.top + 3,
windowRect.left + 19,
windowRect.top + 19
);
DrawPane( pat, thisRect, drawColor );
DrawGoAway( thisRect, false, drawColor );
}
/* ——————————————————————————————— the zoom box */
if ( theWindow.zoomFlag )
{
SetRect( &thisRect,
windowRect.right - 19,
windowRect.top + 3,
windowRect.right - 3,
windowRect.top + 19
);
DrawPane( pat, thisRect, drawColor );
DrawZoom( thisRect, false, drawColor );
}
/* ——————————————————————————————— the title */
SetRect( &thisRect,
windowRect.left + 20,
windowRect.top + 3,
windowRect.right - (( theWindow.zoomFlag ) ? 21 : 3),
windowRect.top + 17
);
PenSize( 1, 1 );
if ( thisRect.right - thisRect.left > 0 )
DrawWindowTitle( window, thisRect, pat, true, drawColor );
} else
{
/* ——————————————————————————————— the blank title bar */
if ( !drawColor )
{
thisRect.top += 2;
thisRect.left += 2;
thisRect.bottom = thisRect.top + 14;
thisRect.right -=2;
DrawPane( pat, thisRect, drawColor );
}
/* ——————————————————————————————— the title */
SetRect( &thisRect,
windowRect.left + 20,
windowRect.top + 3,
windowRect.right - 19,
windowRect.top + 17
);
DrawWindowTitle( window, thisRect, pat, false, drawColor );
}
break;
case ( dBoxProc ): /* dialog box variation */
DrawFrame( pat, thisRect, 4, drawColor );
thisRect.right -= 2;
thisRect.bottom -= 2;
OffsetRect( &thisRect, 1, 1 );
InsetRect( &thisRect, 5, 5 );
PenSize( 2, 2 );
if ( drawColor )
{
PenPat( &pat->black );
RGBForeColor( &pat->cFrameL );
} else
PenPat( &pat->white );
FrameRect( &thisRect );
break;
case ( altDBoxProc ): /* shadow box variation */
case ( altDBoxProc | 4 ): /* remain consistant w/ Apple */
thisRect.right -= 2;
thisRect.bottom -= 2;
FrameRect( &thisRect );
PenSize( 2, 2 );
if ( drawColor )
RGBForeColor( &pat->cGray );
MoveTo( thisRect.left + 2, thisRect.bottom );
LineTo( thisRect.right, thisRect.bottom );
LineTo( thisRect.right, thisRect.top + 2 );
break;
default: /* plain box variation (plainDBox) and others */
PenPat( &pat->black );
FrameRect( &thisRect );
break;
}
break;
case ( wInGoAway ):
SetRect( &thisRect, /* just toggle the goAway */
windowRect.left + 3,
windowRect.top + 3,
windowRect.left + 19,
windowRect.top + 19
);
buttonState = !buttonState;
DrawGoAway( thisRect, buttonState, drawColor );
break;
case ( wInZoomIn ):
case ( wInZoomOut ):
SetRect( &thisRect, /* just toggle the zoomBox */
windowRect.right - 19,
windowRect.top + 3,
windowRect.right - 3,
windowRect.top + 19
);
buttonState = !buttonState;
DrawZoom( thisRect, buttonState, drawColor );
break;
default:
break;
}
} /* end of DrawOnce() */
/*————————————————————
drawing my window
————————————————————*/
DrawMyWindow( int var, WindowPtr window, long param )
{
SysEnvRec thisWorld;
CGrafPtr wPort,
savePort;
Boolean hasColorQD;
PenState savePen;
RGBColor savePnClr,
saveBkClr;
PixPatHandle savePnPat,
saveBkPat,
saveFillPat;
RgnHandle saveClip,
tempRgn;
PatsRec patStore;
PatsPtr pat;
Rect windowRect;
GDHandle aDevice;
AuxWinHandle theAuxWin;
theAuxWin = nil;
savePnPat = nil;
if ( !theWindow.visible ) return;
pat = &patStore;
if ( !SysEnvirons( 1, &thisWorld ) )
hasColorQD = thisWorld.hasColorQD;
else
hasColorQD = false;
if ( hasColorQD )
{
GetPort( &savePort );
GetCWMgrPort( &wPort );
SetPort( wPort );
savePnPat = NewPixPat();
saveBkPat = NewPixPat();
saveFillPat = NewPixPat();
CopyPixPat( wPort->pnPixPat, savePnPat );
CopyPixPat( wPort->bkPixPat, saveBkPat );
CopyPixPat( wPort->fillPixPat, saveFillPat );
GetForeColor( &savePnClr );
GetBackColor( &saveBkClr );
pat->cBlack = PackGray( 0 );
pat->cDark = PackGray( 0x4000 );
pat->cGray = PackGray( 0x8000 );
pat->cLight = PackGray( 0xC000 );
pat->cWhite = PackGray( 0xFFFF );
GetAuxWin( window, &theAuxWin );
if ( theAuxWin )
{
HLock( (*theAuxWin)->awCTable );
pat->cText = (*(*theAuxWin)->awCTable)->ctTable[2].rgb;
pat->cHilite = (*(*theAuxWin)->awCTable)->ctTable[3].rgb;
pat->cTitle = (*(*theAuxWin)->awCTable)->ctTable[4].rgb;
/* The code below makes sure the System 7 colors are found even when the window color
table is defined with only 5 colors! This defines the outline colors of the
frame and buttons. */
if ( (*(*theAuxWin)->awCTable)->ctSize < 12 )
GetAuxWin( nil, &theAuxWin );
if ( (*(*theAuxWin)->awCTable)->ctSize >= 12 )
{
pat->cFrameL = (*(*theAuxWin)->awCTable)->ctTable[11].rgb;
pat->cFrameD = (*(*theAuxWin)->awCTable)->ctTable[12].rgb;
if ( !(pat->cFrameD.red | pat->cFrameD.green | pat->cFrameD.blue) )
hasColorQD=false;
} else
{
pat->cFrameL = pat->cLight;
pat->cFrameD = pat->cDark;
}
HUnlock( (*theAuxWin)->awCTable );
} else
{
pat->cText = pat->cBlack;
pat->cHilite = pat->cLight;
pat->cTitle = pat->cWhite;
}
}
saveClip = NewRgn();
tempRgn = NewRgn();
GetClip( saveClip );
windowRect = (**theWindow.strucRgn).rgnBBox;
/* Align the pattern to the position of the window to prevent shifting durring a drag. */
pat->gray[0] = pat->gray[1] = ((windowRect.left^windowRect.top) & 0x0001) ? gray1Hex:gray2Hex;
pat->black[0] = pat->black[1] = blackHex;
pat->white[0] = pat->white[1] = whiteHex;
GetPenState( &savePen );
if ( hasColorQD )
{
aDevice = GetDeviceList();
do
{
if ( TestDeviceAttribute( aDevice, screenDevice ) &&
TestDeviceAttribute( aDevice, screenActive ) )
{
HLock( aDevice );
if ( RectInRgn( &(**aDevice).gdRect, saveClip ) )
{
RectRgn( tempRgn, &(**aDevice).gdRect );
SectRgn( saveClip, tempRgn, tempRgn );
SetClip( tempRgn );
DrawOnce( param, var, window, windowRect, pat,
((**(**aDevice).gdPMap).cmpSize >= 2 ));
}
HUnlock( aDevice);
}
} while ( (aDevice = GetNextDevice( aDevice )) != nil );
} else
DrawOnce( param, var, window, windowRect, pat, false );
SetClip( saveClip );
DisposeRgn( saveClip );
DisposeRgn( tempRgn );
SetPenState( &savePen );
if ( savePnPat ) // Since hasColorQD may have changed, we check for presence of Handle.
{
RGBForeColor( &savePnClr );
RGBBackColor( &saveBkClr );
CopyPixPat( savePnPat, wPort->pnPixPat );
CopyPixPat( saveBkPat, wPort->bkPixPat );
CopyPixPat( saveFillPat, wPort->fillPixPat );
DisposPixPat( savePnPat );
DisposPixPat( saveBkPat );
DisposPixPat( saveFillPat );
SetPort( savePort );
}
} /* end of DrawMyWindow() */
/*————————————————————
draw a black and white Icon!
————————————————————*/
PlotSICN( Rect theRect, Ptr theSICN )
{
BitMap srcBits; /* built up around 'SICN' data so we can _CopyBits */
GrafPtr wPort;
GetPort( &wPort );
/* set up the small icon's bitmap */
srcBits.baseAddr = theSICN;
srcBits.rowBytes = 2;
SetRect( &srcBits.bounds, 0, 0, 16, 16 );
/* draw the small icon in the current grafport */
CopyBits( &srcBits,&wPort->portBits,&srcBits.bounds,&theRect,srcCopy,nil );
} /* end of PlotSICN() */
/*————————————————————
draw a color icon!
————————————————————*/
PlotCICN( Rect theRect, Ptr theCICN )
{
PixMap srcBits; // built up around 'CICN' data so we can _CopyBits
int i;
CGrafPtr wPort;
RGBColor savePnClr,
saveBkClr,
myRGB;
Handle myCTHandle;
AuxWinHandle theAuxWin;
myCTHandle = nil;
theAuxWin = nil;
myCTHandle = NewHandle( 40 ); // theColorTable!
if ( myCTHandle )
{
HLock( myCTHandle );
myCTable.ctSeed = GetCTSeed(); // Unique Seed
myCTable.ctFlags = 0; // Empty for Color Tables
myCTable.ctSize = 3; // 4 Colors
for ( i=0; i<=3; i++ )
myCTable.ctTable[i].value = i; // Colors in sequence
myCTable.ctTable[1].rgb = PackGray( 0x8000 ); // The Default Colors.
myCTable.ctTable[3].rgb = PackGray( 0x0000 );
GetAuxWin( nil, &theAuxWin );
if ( theAuxWin &&
(*(*theAuxWin)->awCTable)->ctSize >= 12 &&
(*(*theAuxWin)->awCTable)->ctTable[11].rgb.red |
(*(*theAuxWin)->awCTable)->ctTable[11].rgb.green |
(*(*theAuxWin)->awCTable)->ctTable[11].rgb.blue )
{
// System 7 Shading Colors
myCTable.ctTable[0].rgb = (*(*theAuxWin)->awCTable)->ctTable[11].rgb;
myCTable.ctTable[2].rgb = (*(*theAuxWin)->awCTable)->ctTable[12].rgb;
} else
{
myCTable.ctTable[0].rgb = PackGray( 0xFFFF ); // The Default Colors.
myCTable.ctTable[2].rgb = PackGray( 0x4000 );
}
}
GetForeColor( &savePnClr );
myRGB = PackGray( 0x0000 );
RGBForeColor( &myRGB ); // Black
GetBackColor( &saveBkClr );
myRGB = PackGray( 0xFFFF );
RGBBackColor( &myRGB ); // White
if ( myCTHandle )
HUnlock( myCTHandle );
GetPort( &wPort );
srcBits.baseAddr = theCICN;
srcBits.rowBytes = 0x8004; // bit 15 indicates PixMap
SetRect( &srcBits.bounds, 0, 0, 16, 16 );
srcBits.pmVersion = srcBits.packType = srcBits.pixelType = 0;
srcBits.packSize = srcBits.planeBytes = srcBits.pmReserved = 0L;
srcBits.hRes = srcBits.vRes = 72;
srcBits.pixelSize = srcBits.cmpSize = 2;
srcBits.cmpCount = 1;
srcBits.pmTable = (CTabHandle)myCTHandle; // nil if not created
// draw the color icon in the current grafport
CopyBits( &srcBits,*wPort->portPixMap,&srcBits.bounds,&theRect,srcCopy,nil );
if ( myCTHandle )
DisposHandle( myCTHandle );
RGBForeColor( &savePnClr );
RGBBackColor( &saveBkClr );
} /* end of PlotCICN() */
/*————————————————————
CopyRight Notice
————————————————————*/
CopyRight()
{
/* The Following Copyright Notice Is Not To Be Removed! Use Of This Code In Commercial
Software Will Be By License Only. Contact Anthony D. Saxton, Of Elenay™ Creations
For Licensing Information. Use Of This Code In FreeWare, Requires Only Contact Of
Elenay™ Creations. This Copyright Applies To All Code Segments Of This WDEF. */
Str63 Copyright = "Copyright©1993–Elenay™Creations,702/453–0270,"
"All Rights Reserved";
}